package homework;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class SortString {
    public static void main(String[] args) {
        List<String> list=new ArrayList<>();
        list.add("鸡你");
        list.add("实在太美");
        list.add("ohbaby");
        list.add("实在是太美");
        list.add("多一眼就会爆炸");
        list.add("近一点快被融化");
        System.out.println("list:"+list);
        /*
        Collections.sort(list, new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                return o1.length()-o2.length();
            }
        });

         */

        list.sort((o1, o2) -> o1.length()-o2.length());//升序
        System.out.println("list:"+list);
    }
}
